<template>
  <div class="app-container">
    <div class="list-header">
      <el-form :inline="true" :model="from" class="demo-form-inline" size="small">
        <el-form-item>
          <el-input v-model="from.num" placeholder="计划编号" />
        </el-form-item>
        <el-form-item>
          <el-select v-model="from.workType" placeholder="工作类型">
            <el-option label="巡视" value="shanghai" />
            <el-option label="消缺" value="beijing" />
            <el-option label="验收" value="beijing" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-date-picker
            v-model="value1"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
          />
        </el-form-item>
        <el-form-item>
          <el-select v-model="from.planType" placeholder="计划类型">
            <el-option label="巡视" value="shanghai" />
            <el-option label="消缺" value="beijing" />
            <el-option label="验收" value="beijing" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select v-model="from.status" placeholder="计划状态">
            <el-option label="巡视" value="shanghai" />
            <el-option label="消缺" value="beijing" />
            <el-option label="验收" value="beijing" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary">搜索</el-button>
          <el-button type="primary">重置</el-button>
        </el-form-item>
      </el-form>
      <div>
        <el-button type="primary" size="small">导入</el-button>
      </div>
    </div>
    <div class="list-container">
      <el-table
        v-loading="listLoading"
        :data="list"
        element-loading-text="Loading"
        border
        fit
        highlight-current-row
      >
        <el-table-column align="center" label="ID" width="95">
          <template slot-scope="scope">
            {{ scope.$index }}
          </template>
        </el-table-column>
        <el-table-column label="计划编号">
          <template slot-scope="scope">
            {{ scope.row.title }}
          </template>
        </el-table-column>
        <el-table-column label="计划编号" width="110" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.author }}</span>
          </template>
        </el-table-column>
        <el-table-column label="工作地点" width="110" align="center">
          <template slot-scope="scope">
            {{ scope.row.pageviews }}
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { getPlanList } from '@/api/plan'

export default {
  name: 'PlanIndex',
  data() {
    return {
      value1: [],
      from: {
        num: '',
        workType: '',
        planType: '',
        status: ''
      },
      listLoading: true,
      list: null
    }
  },
  created() {
    this.getData()
    // const res = getPlanList()
    // console.log(res)
  },
  methods: {
    getData() {
      getPlanList().then(res => {
        console.log(res)
        const { code, data } = res
        if (code === 20000) {
          this.list = data.items
          this.listLoading = false
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
